//
//  RealTimeHeartRateModel.swift
//  MYModule
//
//  Created by 尹琼 on 2022/11/10.
//


/// 单次测量心率

import UIKit
import SQLite
import SwiftDate
import HandyJSON
import MYModule

open class SingleHeartRateModel: NSObject, MYSQLiteTableiabe, SingleSQLite, HandyJSON {
    
    public var adress: String = ""
    
    public var id: Int64 = 0
    
    public var date: Date = Date().sqlDate()
    
    public var heartRate: Int = 0
    
    /// 结束测量时间戳
    public var end: Double = 0
    
    required public override init() {}
    
    @discardableResult
    public func updateData() ->Bool {
        
        if heartRate <= 0 || heartRate >= 255 {
            return false
        }
        if end <= 0 {
            return false
        }
        
       
        
        if id == 0 {
            insert()
            return true
        }
        
        update()
        return true
        
    }
    

    
}
